Page({
    data: {
      isAdmin: false, // 是否为管理员
      items: [],
    },
  
    onLoad() {
      const currentUser = wx.getStorageSync('currentUser');
  
      if (currentUser && currentUser.role === 'admin') {
        this.setData({ isAdmin: true });
      }
  
      // 加载物品列表
      const app = getApp();
      this.setData({ items: app.globalData.items });
    },
  
    navigateToAddItem() {
      if (!this.data.isAdmin) {
        wx.showToast({
          title: '无权限操作',
          icon: 'none',
          duration: 1500,
        });
        return;
      }
  
      wx.navigateTo({
        url: '/pages/add-item/add-item',
      });
    },
  });